﻿@model IEnumerable<MongoDBSample.Models.DB.Attachment>

@{
    ViewBag.Title = "Mongo DB Sample Attachments";
}

@section featured {
    <section class="featured">
        <div class="content-wrapper">
            <hgroup class="title">
                <h1>@ViewBag.Title</h1>
            </hgroup>
        </div>
    </section>
}
<style>
    table {
        width: 100%;
    }

    thead {
        background-color: #aeaeae;
    }

    td {
        width: 150px;
    }
</style>
<p>
    @Html.ActionLink("New Attachment", "Create")
</p>
<table>
    <thead>
        <tr>
            <th>Attachment Name</th>
            <th>User Name</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var attachment in Model)
        {    
            <tr>
                <td>@Html.ActionLink(attachment.Name, "ViewJarFile", new { Id = attachment.FileId })</td>
                <td>@attachment.Owner</td>
                @if (User.Identity.Name.Equals(attachment.Owner))
                {
                    <td>@Html.ActionLink("Delete", "Delete", new { id = attachment.Id })</td>
                }
                else
                {
                    <td />
                }
            </tr>
        }
    </tbody>

</table>
